<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">

		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">客户姓名</label>
						<div class="layui-input-inline">
							<input type="text" id="customer"  autocomplete="off" class="layui-input" placeholder="请输入客户姓名">
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" class="layui-btn layui-btn-primary cu_ss"  lay-filter="data-search-btn">
							<i class="layui-icon"></i> 搜 索
						</button>
					</div>
				</div>
			</form>
		</fieldset>

		<script type="text/html" id="toolbarDemo">
			<div class="layui-btn-container">
				<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加客户 </button>
				<!--<button class="layui-btn layui-btn-success layui-btn-sm data-add-btn" lay-event="newacc"> 开通账户</button>-->
			</div>
		</script>

		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

		<script type="text/html" id="currentTableBar">
			<a class="layui-btn layui-btn-success layui-btn-xs layui-btn-warm" lay-event="edit">修改</a>
			<a class="layui-btn layui-btn-success layui-btn-xs layui-btn-normal" lay-event="cz">充值</a>
			<a class="layui-btn layui-btn-success layui-btn-xs layui-btn-normal" lay-event="mx">明细</a>
		</script>

	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
//添加
function get_add(){
	layer.open({
        type: 2,
        title:'添加客户信息',
        area: ['60%', '80%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('add_customer')}" 
    });
    //layer.full(index);
}
//修改
function get_save(id){
	layer.open({
        type: 2,
        title:'修改客户信息',
        area: ['60%', '60%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('save_customer')}?id="+id 
    });
    //layer.full(index);
}

//快捷充值
function get_cz(id){
	layer.open({
        type: 2,
        title:'快捷充值',
        area: ['100%', '100%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('top_up')}?id="+id
    });
    //layer.full(index);
}
//明细
function get_mx(id){
	layer.open({
        type: 2,
        title:'明细', 
        area: ['80%', '80%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('cu_fund_inmfo')}?id="+id
    });
}
	var $,form,table,laydate,tableSelect,miniTab;
	layui.use(['form', 'table', 'tableSelect', 'laydate', 'miniTab'], function () {
		$ = layui.jquery
			, form = layui.form
			, table = layui.table
			, laydate = layui.laydate
            , tableSelect = layui.tableSelect
            , miniTab = layui.miniTab
			;
		pageLoading();
		table.render({
			elem: '#currentTableId',
			id:'testReload',
			height: 'full-150',
			url: '{:url("customer")}?t=json',
			method : 'post',
			toolbar: '#toolbarDemo',
			loading:false,
			cols: [[
				{ field: 'name', title: '客户名称' ,width:180},
				{ field: 'username', title: '媒介',width:160},
				{ field: 'delivery', align: 'center', title: '在投/总计',width:160 },
				{ field: 'prepare_money', align: 'right', title: '备款',sort: true ,width:120},
				{ field: 'total_recharge', align: 'right', title: '打款总计',sort: true ,width:120},
				{ field: 'total_acc_recharge', align: 'right', title: '账户币总计', sort: true ,width:120},
				{ field: 'total_currency_consume', align: 'right', title: '账户币总消耗', sort: true ,width:130},
				{ field: 'create_time', title: '创建时间', sort: true ,width:160},
				{ field: 'note', title: '备注',width:160},
				{ field: 'card_number', title: '银行卡号',width:180 },
			    { field: 'bank_name', title: '开户行地址' ,width:180},
			    { field: 'zfb_num', title: '支付宝账号' ,width:180},
				{ title: '操作',fixed: 'right', toolbar: '#currentTableBar', align: "center",width:160 }//center
			]],
			limit: 30,
			page: true,
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});

		// 监听搜索操作
		$('.cu_ss').click(function(){
			pageLoading();
			var name = $("#customer").val();
			table.reload('testReload', {
				  url: '{:url("customer")}?t=json',
				  where:{name:name}
				});
		});
		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(currentTableFilter)', function (obj) {
			switch (obj.event) {
				case 'add':
					get_add();
				break;
				case 'newacc':
					get_acc();
				break;
				
			}
			
		});

		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					get_save(data.id);
				break;
				case 'cz':
					get_cz(data.id);
				break;
				case 'mx':
					get_mx(data.id);
				break;
			}
			
		});

	});
	//重载数据表
	function get_s(msg){
		pageLoading();
		table.reload('testReload', {
			  url: '{:url("customer")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>

</body>
</html>